﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;

namespace WXYW
{
    public partial class AllSparePartApplyRecords : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindSparePartForms();
            }
        }

        private void BindSparePartForms()
        {
            SparePartApplyService service = new SparePartApplyService();
            saprePartGridView.DataSource = service.GetUpgrateFoemByKeywords(keyWordTextBox.Text);
            saprePartGridView.DataBind();
        }

        protected void saprePartGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            if (e.NewPageIndex >= 0 && e.NewPageIndex < saprePartGridView.PageCount)
            {
                saprePartGridView.PageIndex = e.NewPageIndex;
            }
            
            BindSparePartForms();
        }

        protected void searchLinkButton_Click(object sender, EventArgs e)
        {
            BindSparePartForms();
        }

        protected void resetLinkButton_Click(object sender, EventArgs e)
        {
            keyWordTextBox.Text = "";
            BindSparePartForms();
        }

        protected void viewLinkButton_Click(object sender, EventArgs e)
        {
            string spaID = ((LinkButton)sender).CommandArgument;
            Response.Redirect(string.Format("SparePartApplyRecordDetail.aspx?{0}={1}", Constants.QUERYSTR_SPAREPARTAPPLY_ID, spaID));
        }
    }
}
